﻿using BLL;
using Model;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace echuCMS
{
    public partial class FormLogin : Form
    {
        public FormLogin()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
           
            string userName = this.txt_userName.Text.Trim();
            //密码
            string passWord = this.txt_passWord.Text.Trim();
            string md5passWord = Pub.GetMD5(passWord);
            SalesMan salesMan = SalesManService.getSalesMan(userName,passWord,md5passWord);

            //验证用户名密码MAC是否一致
            if (salesMan != null)
            {//存在，则打开主页面
                //    //检查是否记住密码，记住则保存
                //    if (this.checkBoxRememberMe.Checked)
                //    {
                //        Configuration cfa = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
                //        cfa.AppSettings.Settings["rememberMe"].Value = "true";
                //        cfa.AppSettings.Settings["userName"].Value = txt_userName.Text.Trim(); // 账号（默认记住）
                //        cfa.AppSettings.Settings["passWord"].Value = txt_passWord.Text.Trim(); // 密码
                //        cfa.Save();
                //    }
                //    else
                //    {
                //        Configuration cfa = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
                //        cfa.AppSettings.Settings["rememberMe"].Value = "";
                //        cfa.AppSettings.Settings["userName"].Value = ""; // 账号（默认记住）
                //        cfa.AppSettings.Settings["passWord"].Value = ""; // 密码
                //        cfa.Save();
                //    }
                Pub.salesMan = salesMan;
                MDIMain form_Main = new MDIMain();
                form_Main.Show();
                this.Hide();
        }
            else
            {
                //不存在，不做动作
            }
        }
    }
}
